import React, { useState } from 'react';
import { Modal } from 'antd';

function CloseApp(props) {
  // const [visible, setVisible] = useState(false);
  const { visible, setVisible, quitData } = props;
  return (
    <div>
      <Modal
        title="关闭提示"
        visible={visible}
        okText="确认"
        cancelText="取消"
        onCancel={() => {
          setVisible(false);
        }}
        onOk={() => {
          window.electron.ipcRenderer.sendMessage('quit:Task');
        }}
      >
        <div>
          当前还有
          {quitData?.uploadTasks?.length
            ? `${quitData?.uploadTasks?.length}个上传任务,`
            : ''}
          {quitData?.downloadTasks?.length
            ? `${quitData?.downloadTasks?.length}个下载任务`
            : ''}
          在进行中。此时退出应用程序，将会中断上传和下载。是否坚持退出?
        </div>
      </Modal>
    </div>
  );
}

export default CloseApp;
